'use strict';

module.exports = app => {
  const { INTEGER, STRING, DECIMAL, DATE } = app.Sequelize;

  const book = app.model.define('Book', {
    id: {
      field: 'id',
      type: INTEGER,
      primaryKey: true,
    },
    isbn: {
      field: 'isbn',
      type: STRING(25),
    },
    name:{
      type: STRING(50),
    },
    coverImgUrl:{
      field: 'cover_img_url',
      type: STRING(250),
    },
    type: {
      type: INTEGER,
    },
    author: {
      type: STRING(50),
    },
    publishingHouse: {
      field: 'publishing_house',
      type: STRING(50),
    },
    description: {
      type: STRING(250),
    },
    price: {
      type: DECIMAL(5, 2),
      defaultValue: 0
    },
    position: {
      type: STRING(250),
    },
    recommended: {
      field: 'recommended',
      type: INTEGER,
      defaultValue: 0
    },
    lended: {
      field: 'lended',
      type: INTEGER,
      defaultValue: 0
    },
    onSale: {
      field: 'on_sale',
      type: INTEGER,
      defaultValue: 1
    },
    createBy: { field: 'create_by', type: STRING(50), allowNull: true },
    createDate: { field: 'create_date', type: DATE, allowNull: true },
    updateBy: { field: 'update_by', type: STRING(50), allowNull: true },
    updateDate: { field: 'update_date', type: DATE, allowNull: true },
  },
    {
      timestamps: false,
      tableName: 'book',
      created_at: false,
      updated_at: false,

    });

  return book;
};

